/*
 * Copyright (C) 2006 Erik Swenson - erik@oreports.com
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA.
 *  
 */

package org.efs.openreports.engine.output;

import java.io.Serializable;

/**
 * This object contains the report content generated by the ReportEngine as a
 * btye[] along with additional information decribing the content
 * 
 * @author Erik Swenson
 */

public class ReportEngineOutput implements Serializable
{		
	private static final long serialVersionUID = -1891016289500829002L;
	
	public static final String CONTENT_TYPE_PDF = "application/pdf";
	public static final String CONTENT_TYPE_XLS = "application/vnd.ms-excel";
	public static final String CONTENT_TYPE_HTML = "text/html";
	public static final String CONTENT_TYPE_CSV = "text/comma-separated-values";
	public static final String CONTENT_TYPE_RTF = "application/rtf";
	public static final String CONTENT_TYPE_TEXT = "text/plain";
	public static final String CONTENT_TYPE_XML = "application/xml";
	public static final String CONTENT_TYPE_JPEG = "image/jpeg";
	public static final String CONTENT_TYPE_PNG = "image/png";		
	
	private String contentType;
	private String contentMessage;	
	private byte[] content;			
	
	public byte[] getContent()
	{
		return content;
	}

	public void setContent(byte[] content)
	{
		this.content = content;
	}

	public String getContentType()
	{
		return contentType;
	}

	public void setContentType(String contentType)
	{
		this.contentType = contentType;
	}
	
	public String getContentMessage()
	{
		return contentMessage;
	}

	public void setContentMessage(String contentMessage)
	{
		this.contentMessage = contentMessage;
	}

	public String getContentExtension()
	{	
		if (contentType == null) return "";
		
		if (contentType.equals(CONTENT_TYPE_PDF))
		{
			return ".pdf";
		}
		else if (contentType.equals(CONTENT_TYPE_XLS))
		{
			return ".xls";
		}
		else if (contentType.equals(CONTENT_TYPE_HTML))
		{
			return ".html";
		}
		else if (contentType.equals(CONTENT_TYPE_CSV))
		{
			return ".csv";
		}
		else if (contentType.equals(CONTENT_TYPE_RTF))
		{
			return ".rtf";
		}
		else if (contentType.equals(CONTENT_TYPE_TEXT))
		{
			return ".txt";
		}
		else if (contentType.equals(CONTENT_TYPE_XML))
		{
			return ".xml";
		}
		else if (contentType.equals(CONTENT_TYPE_JPEG))
		{
			return ".jpg";
		}
		else if (contentType.equals(CONTENT_TYPE_PNG))
		{
			return ".png";
		}
		
		return "";
	}
	
	public void setContentExtension(String contentExtension)
	{
		// empty setter
	}
}
